﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Wpf.Telemetry
{
    public sealed class NativeMethods
    {
        private NativeMethods() { } 
        
        private struct MemoryStatus
        {
            public uint Length;
            public uint MemoryLoad;
            public uint TotalPhysical;
            public uint AvailablePhysical;
            public uint TotalPageFile;
            public uint AvailablePageFile;
            public uint TotalVirtual;
            public uint AvailableVirtual;
        }

        [DllImport("kernel32.dll")]
        private static extern void GlobalMemoryStatus(out MemoryStatus stat);

        public static long GetTotalPhysicalMemory()
        {
            MemoryStatus status = new MemoryStatus();
            GlobalMemoryStatus(out status);
            return (long)status.TotalPhysical;
        }
    }
}
